import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout_c'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* redirect: noredirect           if `redirect:noredirect` will no redirct in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
{ path: '/404', component: () => import('@/views/404'), meta: { unCheckLogin: true }, hidden: true },
{ path: '*', redirect: '/404', hidden: true },
    {
        path: '/',
            component: Layout,
        redirect: '/list',
        name: 'List',
        hidden: true,
        meta: { unCheckLogin: true },
        children: [{
            path: 'list',
            meta: { unCheckLogin: true },
            component: () => import('@/views/c/index')
        }]
    },
    {
    path: '/product',
    component: Layout,
    name: 'Product',
    children: [
      {
        path: 'detail/:id',
        name: 'productDetail',
        meta: { unCheckLogin: true },
        component: () => import('@/views/c/product/detail')
      },
      {
        path: 'mgm',
        name: 'nocoupons',
        component: () => import('@/views/c/product/nocoupons')
      },
      {
        path: 'submit/:orderId',
        name: 'submitProduct',
        component: () => import('@/views/c/product/submit')
      }
    ]
  },
    {
        path: '/coupon',
        component: Layout,
        name: 'coupon',
        children: [
            {
                path: 'index',
                name: 'couponIndex',
                component: () => import('@/views/c/coupon/index')
            },
            {
                path: 'adapt/:id',
                name: 'couponAdapt',
                component: () => import('@/views/c/coupon/adapt')
            },
            {
                path: 'mgm',
                meta: { unCheckLogin: true },
                name: 'couponMgm',
                component: () => import('@/views/c/coupon/mgm')
            }
        ]
    },
    {
        path: '/order',
        component: Layout,
        name: 'order',
        children: [
        {
            path: 'index',
            name: 'orderIndex',
            component: () => import('@/views/c/order/index')
        },
        {
            path: 'detail/:id',
            name: 'orderDetail',
            component: () => import('@/views/c/order/detail')
        }
     ]
    },
    {
        path: '/member/:status',
        meta: { unCheckLogin: true },
        component: () => import('@/views/c/person/logReg'),
        name: 'regist'
    },
    {
        path: '/mgm',
        meta: { unCheckLogin: true },
        component: () => import('@/views/c/mgm/callBack'),
        name: 'mgmCallBack'
    },
    {
        path: '/help',
        meta: { unCheckLogin: true },
        component: Layout,
        redirect: '/help/list',
        name: 'helpIndex',
        children: [
            {
                path: 'list',
                meta: { unCheckLogin: true },
                name: 'helpList',
                component:() => import('@/views/c/help')
            }
        ]
    }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})

